export default {
    namespaced: true,
    state: {
        isShowToast: false,
        toastMsg: "这是默认的提示信息",
        toastType: "success"
    },
    mutations: {
        changeIsShowToast(state, payload) {
            state.isShowToast = payload.isShow
            // 防止不赋值，导致默认赋空值，动画消失时出现椭圆形的现象，影响用户体验
            if (payload.isShow) {
                state.toastMsg = payload.tMsg
                state.toastType = payload.tType
            }

        }
    },
    actions: {
        asyncChangeIsShowToast(context, payload) {
            context.commit("changeIsShowToast", payload);
            setTimeout(() => {
                context.commit("changeIsShowToast", {
                    isShow: false
                })
            }, 2000)
        }
    }
}